#include <stdio.h>
#include <stdlib.h>

#define MAX_N 1000
#define MAX_K 10


typedef struct {
    int t, p, vip; 
} Cust;


typedef struct {
    int end, cnt; 
} Win;

Cust cust[MAX_N];
Win win[MAX_K];
int N, K, vip_id;
int cmp(const void *a, const void *b) {
    return ((Cust *)a)->t - ((Cust *)b)->t;
}
int find_win(int is_vip) {
    int min_t = 1e9, idx = -1;
    for (int i = 0; i < K; i++) {
        if (win[i].end < min_t || (win[i].end == min_t && i < idx)) {
            if (!is_vip || i == vip_id || win[vip_id].end > win[i].end) {
                min_t = win[i].end;
                idx = i;
            }
        }
    }
    return idx;
}

int main() {
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        scanf("%d %d %d", &cust[i].t, &cust[i].p, &cust[i].vip);
        if (cust[i].p > 60) {
            cust[i].p = 60;
        }
    }
    scanf("%d %d", &K, &vip_id);
    qsort(cust, N, sizeof(Cust), cmp);
    for (int i = 0; i < K; i++) {
        win[i].end = 0;  
        win[i].cnt = 0;  
    }
    int total_wait = 0, max_wait = 0, last_end = 0;
    for (int i = 0; i < N; i++) {
        int w = find_win(cust[i].vip);
        int start = cust[i].t > win[w].end ? cust[i].t : win[w].end;
        int wait = start - cust[i].t;
        total_wait += wait;
        if (wait > max_wait) max_wait = wait; 
        last_end = start + cust[i].p;
        win[w].end = last_end;
        win[w].cnt++;
    }
    printf("%.1f %d %d\n", total_wait / (double)N, max_wait, last_end);
    for (int i = 0; i < K; i++) {
        printf("%d%c", win[i].cnt, i == K - 1 ? '\n' : ' ');
    }
    return 0;
}
